package service.impl;

import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import dao.CustomerDao;
import pojo.Customer;
import service.CustomerManager;
@Service(value="customerManager")
public class CustomerManagerImpl implements CustomerManager{
	@Resource(name="customerDao")
	private CustomerDao cd;
	@Override
	@Transactional
	public Customer regist(Customer c) {
		c.setId(UUID.randomUUID().toString());
		return cd.addCustomer(c);
	}
	@Override
	public Customer login(String cname, String psd) {
		Customer c= cd.findCustomerByName(cname);
		if(c==null)
		{
			return null;
		}
		if(c.getPassword().equals(psd))
			return c;
		else 
			return null;
	}
}
